<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
<#include "../common/header.ftl">
    <style>
        .modal-body img {
            width: 100%;
        }

        .modal-body {
            max-height: 700px;
            overflow-y: scroll;
        }
    </style>
    <script>
        $(function () {
            $('#pagination').twbsPagination({
                totalPages: ${result.pages},
                startPage: ${result.pageNum},
                visiblePages: ${result.pageSize},
                first: "首页", prev: "上一页",
                next: "下一页",
                last: "末页",
                onPageClick: function (event, page) {
                    $("#currentPage").val(page);
                    $("#searchForm").submit();
                }
            })
            ;
            //查看内容按钮
            $(".showContentBtn").click(function () {
                //获取游记的id
                var id = $(this).data("tid");
                //获取游记内容并回显
                $.get("/travel/getContentById.do", {id: id}, function (data) {
                    $(".modal-body").html(data.content);
                    $("#contentModal").modal('show');
                })
            })

            //发布和拒绝功能
            $(".changeStateBtn").click(function () {
                //获取游记的id
                var id = $(this).data("tid");
                //获取要修改的状态
                var state = $(this).data("state");
                //更改状态
                $.get("/travel/changeState.do", {id: id, state: state}, function (data) {
                    showMessager(data);
                })
            })
        })
    </script>
</head>
<body>

<div class="container " style="margin-top: 20px">
<#include "../common/top.ftl">
    <div class="row">
        <div class="col-sm-3">
        <#include "../common/menu.ftl">
        </div>
        <div class="col-sm-9">
            <div class="row">
                <div class="col-sm-12">
                    <h1 class="page-head-line">待审核游记管理</h1>
                </div>
            </div>
            <!--高级查询-->
            <form class="form-inline" id="searchForm" action="/travelAudit/list.do" method="post">
                <input type="hidden" name="currentPage" id="currentPage" value="1">
                <div class="form-group">
                    <label for="keyword">关键字:</label>
                    <input type="text" class="form-control" id="keyword" name="keyword" value="${(qo.keyword)!}"
                           placeholder="请输入标题">
                    <select id="state" class="form-control" autocomplete="off" name="state">
                        <option value="-2">全部</option>
                        <option value="1">待发布</option>
                        <option value="-1">已拒绝</option>
                    </select>
                    <script>
                        $('#state option[value=' + '${qo.state}' + ']').prop('selected', true);
                    </script>
                    <button id="btn_query" class="btn btn-success">查询</button>
                </div>
            </form>
            <table class="table table-striped table-hover">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>地点</th>
                    <th>作者</th>
                    <th>状态</th>
                </tr>
                </thead>
            <#list result.list as entity>
                <tr>
                    <td>${entity_index+1}</td>
                    <td>${entity.title}</td>
                    <td><img src="${entity.coverUrl}" width="30px"></td>
                    <td>${(entity.place.name)!}</td>
                    <td>${entity.author.nickName}</td>
                    <td>
                        <#if entity.state == -1>
                            拒绝
                        <#elseif entity.state == 0>
                            草稿
                        <#elseif entity.state ==1>
                            待发布
                        <#elseif entity.state ==2>
                            已发布
                        </#if>
                    </td>
                    <td>
                        <a href="javascript:;" class="showContentBtn" data-tid="${entity.id}">查看游记</a>
                    </td>
                    <td>
                        <a href="javascript:;" class="changeStateBtn" data-state="2" data-tid="${entity.id}">发布</a>
                    </td>
                    <td>
                        <a href="javascript:;" class="changeStateBtn" data-state="-1" data-tid="${entity.id}">拒绝</a>
                    </td>
                </tr>
            </#list>
            </table>
            <div style="text-align: center;">
                <ul id="pagination" class="pagination"></ul>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="contentModal" tabindex="-1" role="dialog">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title">游记内容查看</h4>
            </div>
            <div class="modal-body">
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal-dialog -->
</div><!-- /.modal -->
</body>
</html>